<template>
	<view class="container">
		<view class="content">
			<header-view></header-view>
			<view class="add flex_center" @tap="addPath">
				<uni-icons type="plusempty" size="22" style="font-weight: 600;"></uni-icons>
			</view>
			<view class="title">银行卡</view>
			<view class="list">
				<view class="item" v-for="item in list" @tap="addPath(item,'detail')">
					<view class="item_header flex_between">
						<text style="font-size: 36rpx;">{{item.bankname}}</text>
						<text>{{item.bank}}</text>
					</view>
					<view class="item_card">
						{{item.address}}
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import headerView from "@/components/headerView.vue"
	import {
		walletListApi,
	} from "@/api/api.js"
	export default {
		components: {
			headerView
		},
		data() {
			return {
				list: []
			};
		},
		onShow() {
			this.getList()
		},
		methods: {
			getList() {
				const token = uni.getStorageSync('token');
				const type = '1';
				walletListApi({
					token,
					type
				}).then(res => {
					console.log(res.data.data)
					this.list = res.data.data
					console.log(this.list)
				})
			},
			addPath(opt, type) {
				if (type == "detail") {
					console.log(opt.id)
					uni.navigateTo({
						url: "/pages/user/wallet/addBank?id=" + opt.id
					})
				} else {
					uni.navigateTo({
						url: "/pages/user/wallet/addBank"
					})
				}

			},
			copy(opt) {
				console.log(opt)
				uni.setClipboardData({
					data: opt.address,
					success: () => {
						uni.$u.toast("复制成功")
					}
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.container {
		.content {
			padding-bottom: 40rpx;
			position: relative;

			.add {
				position: absolute;
				right: 40rpx;
				top: 40rpx;
				width: 72rpx;
				height: 72rpx;
				background-color: hsla(0, 0%, 92.9%, .46);
				border-radius: 20rpx;
			}

			.title {
				padding-top: 60rpx;
				font-size: 30px;
				font-weight: 500;
				font-family: PM;
				line-height: 92rpx;
			}

			.list {
				padding-top: 40rpx;

				.item {
					font-family: PM;
					background-color: #0065ff;
					background-image: url("../../../static/img/btn_bg.png");
					background-size: cover;
					border-radius: 40rpx;
					padding: 40rpx;
					margin-top: 20rpx;
					margin-bottom: 20rpx;
					color: #fff;

					.item_header {
						font-size: 30rpx;
					}

					.item_card {
						margin-top: 30rpx;
					}
				}
			}
		}
	}
</style>